import 'dart:ui';

import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:flutter_smart_dialog/flutter_smart_dialog.dart';
import 'package:lcapp/model/event/event_bus.dart';
import 'package:lcapp/routes/route.dart';

class FabuMenuPage extends StatefulWidget {
  const FabuMenuPage({Key? key}) : super(key: key);

  @override
  _FabuMenuPageState createState() => _FabuMenuPageState();
}

class _FabuMenuPageState extends State<FabuMenuPage> {
  @override
  Widget build(BuildContext context) {
    return Container(
      height: 1.sh,
      width: 1.sw,
      color: Color.fromRGBO(0, 0, 0, 0.5),
      padding: EdgeInsets.only(bottom: ScreenUtil().bottomBarHeight+20.w),
      child: BackdropFilter(
        filter: ImageFilter.blur(sigmaX: 15, sigmaY: 15),//背景模糊化
        child: Column(
          mainAxisAlignment: MainAxisAlignment.end,
          children: [
            fabuItem('assets/fabu/fabu_sold.png', '发布出售', '轻松交易·快速卖粮','FaBuSoldPage',fabuType: 0),
            fabuItem('assets/fabu/fabu_caigou.png', '发布采购', '严选商家·海量粮源','FaBuSoldPage',fabuType: 1),
            fabuItem('assets/fabu/fabu_video.png', '发布视频', '粮食视频·更多意向','FabuVideoPage'),
            GestureDetector(
              onTap: (){
                SmartDialog.dismiss();
              },
              child: Container(
                width: 80.w,
                height: 80.w,
                decoration: BoxDecoration(
                    gradient: const LinearGradient(
                        colors: [
                          Color(0xffF1783B),
                          Color(0xffF6A456),
                        ],
                        begin: Alignment.topCenter,
                        end: Alignment.bottomCenter
                    ),
                    borderRadius: BorderRadius.circular(80.w)
                ),
                child: Icon(Icons.close,size: 50.w,color: Colors.white,),
              ),
            )
          ],
        ),
      ),
    );
  }

  Widget fabuItem(String icon,String name,String desc,String routeName,{int? fabuType}){
    return GestureDetector(
      onTap: (){
        SmartDialog.dismiss().then((value){
          Navigator.of(ASRRoute.navigatorKey.currentContext!).pushNamed(routeName,arguments: {'fabuType':fabuType});
        });
      },
      child: Container(
        margin: EdgeInsets.only(bottom: 90.w),
        child: Column(
          children: [
            Image.asset(icon,width: 100.w,),
            Text(name,style: TextStyle(
                color: Colors.white,
                fontSize: 32.sp,
                fontWeight: FontWeight.w600
            ),),
            SizedBox(height: 10.w,),
            Text(desc,style: TextStyle(
                color: Colors.white,
                fontSize: 28.sp,
                fontWeight: FontWeight.w500
            ),)
          ],
        ),
      ),
    );
  }
}
